local soundlib = {};

soundlib.baseDir = "sounds/";

soundlib.sounds = {};

---
-- @param baseDirectory
-- @return
function soundlib.setBaseDirectory(baseDirectory)
    soundlib.baseDir = baseDirectory;
end

---
-- @return
function soundlib.loadSound(name, soundFile)
    local sound = audio.loadSound(soundlib.baseDir .. soundFile)
    if sound then        
        soundlib.sounds[name] = sound;
    else
        print("soundlib", "Sound [" .. name .. "] not loaded!!");
    end
end

---
-- @return
function soundlib.playSound(name)
    local sound = soundlib.sounds[name];
    if sound then
        audio.play(sound);
    else
        print("soundlib", "Sound [" .. name .. "] not found!");
    end
end

---
-- @param name
-- @return
function soundlib.dispose(name)
    local sound = soundlib.sounds[name];
    if sound then
        audio.dispose(sound);
    else
        print("soundlib", "Sound [" .. name .. "] not disposed!");
    end
end

---
-- @return
function soundlib.disposeAll()
    for k, v in pairs(soundlib.sounds) do
        soundlib.dispose(k);
    end
end

return soundlib;
